# -*- coding: utf-8 -*-
from typing import Optional, NoReturn
from loguru import logger

from sqlalchemy import DateTime,  select, text, update, delete, desc,insert
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.sql import Select
from sqlalchemy.sql import func

from app.api import jwt
from app.models import Job
from app.schemas.job import ReqCreateJob


from app.schemas.user import CreateUser, DeleteUser, UpdateUser
from app.schemas.project import CreateProjectTimerDao 



async def create_job(db: AsyncSession, create: dict) -> NoReturn:
    await db.execute(insert(Job).values(**create))
    await db.commit()
    


async def get_job_by_job_id(db: AsyncSession, job_id: str) -> Optional[Job]:
    job = await db.execute(select(Job).where(Job.job_id == job_id))
    return job.scalars().first()


async def del_job_by_job_id(db: AsyncSession, job_id: str) -> None:
    await db.execute(delete(Job).where(Job.job_id == job_id))
    await db.commit()




# async def get_project_by_user_id(db: AsyncSession, user_id: int) -> Optional[Project]:
#     project = await db.execute(select(Project).where(Project.user_id == user_id))
#     return project.scalars().all()


